diff options
Diffstat (limited to 'src/pages/kodaira/events/[period].astro')
| -rw-r--r-- | src/pages/kodaira/events/[period].astro | 124 |
1 files changed, 124 insertions, 0 deletions
diff --git a/src/pages/kodaira/events/[period].astro b/src/pages/kodaira/events/[period].astro new file mode 100644 index 0000000..7ef4599 --- /dev/null +++ b/src/pages/kodaira/events/[period].astro @@ -0,0 +1,124 @@ +--- +// 月別・年度別アーカイブ(/kodaira/events/2026-11/、/kodaira/events/r8/ など)。 +// 行事予定のデータ(src/data/schedule/*.json)から、その期間の予定だけを静的に生成する。 +import StarlightPage from '@astrojs/starlight/components/StarlightPage.astro'; +import ScheduleTable from '@/components/ScheduleTable.astro'; +import { + fiscalYearKeys, + fiscalYearLabel, + fiscalYearOf, + monthCounts, + monthKeys, + monthLabel, + monthsInFiscalYear, + rowsInFiscalYear, + rowsInMonth, +} from '@/lib/schedule-months'; +import { SCHEDULE_BASE_PATH } from '@/data/schedule/config'; + +export function getStaticPaths() { + return [ + ...monthKeys.map((key, i) => ({ + params: { period: key }, + props: { + kind: 'month' as const, + key, + prev: monthKeys[i - 1] ?? null, + next: monthKeys[i + 1] ?? null, + }, + })), + ...fiscalYearKeys.map((key, i) => ({ + params: { period: key }, + props: { + kind: 'fiscal' as const, + key, + prev: fiscalYearKeys[i - 1] ?? null, + next: fiscalYearKeys[i + 1] ?? null, + }, + })), + ]; +} + +const { kind, key, prev, next } = Astro.props as { + kind: 'month' | 'fiscal'; + key: string; + prev: string | null; + next: string | null; +}; + +const label = kind === 'fiscal' ? fiscalYearLabel(key) : monthLabel(key); +const periodLabel = (period: string) => + kind === 'fiscal' ? fiscalYearLabel(period) : monthLabel(period); + +const meetingRows = + kind === 'fiscal' ? rowsInFiscalYear(key, 'meeting') : rowsInMonth(key, 'meeting'); +const eventRows = + kind === 'fiscal' ? rowsInFiscalYear(key, 'event') : rowsInMonth(key, 'event'); + +// 年度ページでは、その年度の月別ページへの一覧も並べる。 +const months = kind === 'fiscal' ? monthsInFiscalYear(key) : []; + +const url = (period: string) => `${SCHEDULE_BASE_PATH}${period}/`; +--- + +<StarlightPage + frontmatter={{ + title: `小平市のイベント・行事予定(${label})`, + description: `${label}の小平市のイベントと、審議会・市議会の開催予定の一覧です。日程・会場・申込期限を確認できます。`, + }} +> + <p><a href={SCHEDULE_BASE_PATH}>← 小平市のイベント・行事予定カレンダー(今後)に戻る</a></p> + + <p> + {label}の小平市のイベントと、審議会等・市議会の開催予定です。開催日が過ぎたものも記録として掲載しています。 + 変更になることがありますので、各問い合わせ先へご確認ください。 + </p> + + { + kind === 'fiscal' && ( + <ul class="schedule-month-archive"> + {months.map((month) => ( + <li> + <a href={url(month)}>{monthLabel(month)}の予定</a> + <span class="schedule-month-count">{monthCounts[month]}件</span> + </li> + ))} + </ul> + ) + } + + { + meetingRows.length > 0 && ( + <> + <h2>審議会等・市議会の開催予定</h2> + <div class="schedule-table schedule-table--date-nowrap"> + <ScheduleTable variant="meeting" rows={meetingRows} /> + </div> + </> + ) + } + + { + eventRows.length > 0 && ( + <> + <h2>イベント</h2> + <div class="schedule-table"> + <ScheduleTable variant="event" rows={eventRows} /> + </div> + </> + ) + } + + { + kind === 'month' && ( + <p class="schedule-fiscal-link"> + <a href={url(fiscalYearOf(key))}>{fiscalYearLabel(fiscalYearOf(key))}の予定をまとめて見る</a> + </p> + ) + } + + <nav class="schedule-month-nav" aria-label={kind === 'fiscal' ? '年度の移動' : '月の移動'}> + {prev ? <a href={url(prev)}>← {periodLabel(prev)}</a> : <span />} + {next ? <a href={url(next)}>{periodLabel(next)} →</a> : <span />} + </nav> +</StarlightPage> |
